<template>
  <div id="home">
    <!-- <h1>主页</h1> -->

    <div id="directory">
      <a-row :gutter="16">
        <a-col :span="4" style="margin-bottom: 10px" v-for="item in menuItems" :key="item.key">
          <a-card :bordered="true">
            <span style="color: blue; cursor: pointer" @click="getRouteraa(item)">{{
              item.label
            }}</span>
          </a-card>
        </a-col>
      </a-row>
    </div>

    <div id="content">
      <router-view></router-view>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'
import Directory from '../views/Directory.vue' // 假设 Directory.vue 是普通 Vue 组件
import { type MenuItems, menuItems } from '../layout/menu/menu' // 导入类型和数据
import { useRouter } from 'vue-router'

export default defineComponent({
  components: {
    Directory
  },
  setup() {
    const router = useRouter()
    const getRouteraa = (item: MenuItems) => {
      router.push('/' + item.key)
    }

    const menuItemsRef = ref<MenuItems[]>(menuItems)

    return {
      getRouteraa,
      menuItems: menuItemsRef
    }
  }
})
</script>

<style scoped>
#directory ul {
  list-style-type: none;
  padding-left: 0;
}
#directory li {
  margin-bottom: 5px;
}
#directory a {
  text-decoration: none;
  color: #007bff;
}
#directory a:hover {
  text-decoration: underline;
}
</style>
